package jianzhiOffer;

import java.util.PriorityQueue;

//剑指 Offer 40. 最小的k个数
public class Num40_getLeastNumbers {
    public int[] getLeastNumbers(int[] arr, int k) {
        PriorityQueue<Integer> queue = new PriorityQueue<>();
        for (int i : arr){
            queue.offer(i);

        }
        int []ret = new int[k];
        for (int i = 0; i < k; i++) {
            ret[i]=queue.poll();
        }
        return ret;

    }

}
